<%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8"%>
<%@ taglib prefix="s" uri="/struts-tags" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Insert title here</title>
<style type="text/css">
div{
	background: white;
	width:800px;
	height:600px;
	margin: 0 auto; 
}

</style>
</head>
<script type="text/javascript" src="../js/jquery-1.8.3.js"></script>

<script type="text/javascript">
	$(function(){
		//单击时弹出是否删除的信息
		$(".delete").click(function(){
			var username=$(this).next(":input").val();
			if(confirm("确定要删除"+username+"的信息吗?")){
				document.userForm.action=this.href;
				document.userForm.submit();
				/* var tr=$(this).parent().parent();
				tr.remove();
				var url=this.href;
				var arg={"time":new Date()};
				$.post(url,arg,function(data){
					if(data=="1"){
						alert("删除成功!");
						tr.remove();
					}else{
						alert("删除失败!");
					}
				}); */
			}
			
			return false;
		});
	})
</script>

<body>
<div>
<form action="delete" name="userForm" method="post">
	<table border="1px" cellpadding="15" cellspacing="0px">
		<caption>用户列表</caption>
		<thead>
			<tr>
				<td>Name</td>
				<td>Age</td>
				<td>Email</td>
				<td>Phone</td>
				<td colspan="3" align="center">操作</td>
			</tr>
		</thead>
		<tbody>
			<s:iterator value="#session.page.result">
				<tr align="center">
					<td><s:property value="name"/></td>
					<td><s:property value="age"/></td>
					<td><s:property value="email"/></td>
					<td><s:property value="phone"/></td>
					<td><a href="edit.action?id=<s:property value='id'/>">
					<img src="../images/edit.gif" width="16" height="16" alt="编辑"/>
					</a></td>
					<td><a href="delete.action?id=<s:property value='id'/>" class="delete">
					<img src="../images/delete.gif" width="16" height="16" alt="删除" />
					</a><input type="hidden" value="<s:property value='name'/>"/>
					</td>
					<td><a href="get.action?id=<s:property value='id' />">
					<img src="../images/search.gif" width="16" height="16" alt="查看"/>
					</a></td>
				</tr>
			</s:iterator>
		</tbody>
	</table>
	<div>
		第<s:property value='#session.page.curPageNum'/>页/共<s:property value='#session.page.totalPage'/>页
		<s:if test="#session.page.curPageNum!=1">
			<a href="pageList?curPageNum=1">首页</a>
			<a href="pageList?curPageNum=<s:property value='#session.page.curPageNum-1'/>" >上一页</a>
		</s:if>
		<s:if test="#session.page.curPageNum!=#session.page.totalPage">
			<a href="pageList?curPageNum=<s:property value='#session.page.curPageNum+1'/>" >下一页</a>
			<a href="pageList?curPageNum=<s:property value='#session.page.totalPage'/>">尾页</a>
		</s:if>
		<a href="addPage" >添加用户</a>
	</div>
	</form>
</div>
	
</body>
</html>